package com.ctshk.rpc.scenic.service.impl.app;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.rpc.scenic.dto.app.ScenicProductDTO;
import com.ctshk.rpc.scenic.entity.app.ScenicProductApp;
import com.ctshk.rpc.scenic.mapper.app.ScenicProductAppMapper;
import com.ctshk.rpc.scenic.service.app.IScenicProductAppService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class ScenicProductAppServiceImpl implements IScenicProductAppService {
    @Autowired
    ScenicProductAppMapper scenicProductAppMapper;

    @Override
    public ScenicProductDTO selectScenicProductDTOById(Long id) {
        ScenicProductApp scenicProduct = scenicProductAppMapper.selectOne(new QueryWrapper<ScenicProductApp>().lambda().eq(ScenicProductApp::getId, id));
        ScenicProductDTO scenicProductDTO = new ScenicProductDTO();
        if(scenicProduct != null){
            try{
                BeanUtils.copyProperties(scenicProduct, scenicProductDTO);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return scenicProductDTO;
    }
}
